package com.nc.mem.serial.graph.common;

import static com.nc.mem.serial.graph.Representation.readString;
import static com.nc.mem.serial.graph.Representation.writeString;

import java.nio.ByteBuffer;

import com.nc.mem.serial.graph.GraphSerializer;


public final class StringSerializer extends GraphSerializer {

	public static final StringSerializer INSTANCE = new StringSerializer();

	private StringSerializer() {
	}

	@Override
	public void doRead(final ByteBuffer src, final Object o) {

	}

	@Override
	public void doWrite(final ByteBuffer dest, final Object obj) {
		writeString(dest, (String) obj);
	}

	@Override
	public Object instantiate(final ByteBuffer src) {
		return readString(src);
	}

	public String readNonRootString(final ByteBuffer src) {
		return (String) readNonRoot(src);
	}

}
